<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/ajax2.js"></script>
</head>
<body>
    
    <script>
        /* 
            测试Ajax方法 GET方法的测试
        */    
     /* 
       ajax({
           type:'GET',
           url:'http://www.biwuit.cn/spboot/encapsulationAjaxToolsGet?args=abc',
           success: function(data,request){
               console.log("请求成功")
               console.log(data)
           },
           error: function(data,request){
               console.log("请求失败")
               console.log(data)
               console.log(request)
           }
       }) ; */ 


        /* 
            测试Ajax方法 POST方法的测试
        */    

      /*  ajax({
           type:'POST',
           url:'http://www.biwuit.cn/spboot/encapsulationAjaxToolsPost',
           data:{
               args:'哈哈',
               password:'12345'

           },
           success: function(data,request){
               console.log("post请求成功")
               console.log(data)
           },
           error: function(data,request){
               console.log("post请求失败")
               console.log(data)
               console.log(request)
           }
       }) ; */

       /* 
            测试请求参数为JSON格式
       */

       ajax({
           type:'POST',
           url:'http://www.biwuit.cn/spboot/encapsulationAjaxToolsPostParamsJson',
           data:{
               username:"zhangsan",
               password:"ddd",
               gender:1,

           },
           headr:{
            'Content-Type':"application/json"
           },
           success: function(data,request){
               console.log("json request format 请求成功")
               console.log(data)
           },
           error: function(data,request){
               console.log("json request format 请求失败")
               console.log(data)
               console.log(request)
           }
       }) ;
    </script>

</body>
</html>